#!/usr/bin/python

# mainwindow.py 

import sys
#from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import * 
from PyQt4.QtGui import *

from lib.data import *

class EventWidget(QWidget):
  "The remider screen with shift display."
  """
  The event widget:
  Atributes: time from and to, outlet, location
  outlet is indentified by colour
  More info in the tooltip
  clicking should open edit dialog
  """
  ItemKey = 0
  ER = dict()
  EL = list()
  def __init__(self, parent=None):
    QWidget.__init__(self, parent)
    self.Layout = QHBoxLayout()
    self.setLayout(self.Layout)
      
  def add(self, rec):
    self.getNewItemKey()
    self.ER = {self.ItemKey : rec}
    self.EL = {self.ItemKey : QPushButton(str(self.ItemKey) + ": " + str(rec.get("start")) + "-" + str(rec.get("end"))) }
    self.Layout.addWidget(self.EL[self.ItemKey])
    pass
    
  def getNewItemKey(self):
    self.ItemKey = self.ItemKey + 1
    return self.ItemKey
    
class MainWindow(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)

        self.resize(350, 250)
        self.setWindowTitle('mainwindow')
        #self.setCentralWidget(textEdit)
        #TimeL = QLabel("13:00 - 17:30")
	#SL = QBoxLayout(QBoxLayout.TopToBottom)
	Lt = QHBoxLayout()
        #Lt.addWidget(a)
        #S = EventWidget()
        #self.setCentralWidget(S)
        self.setLayout(Lt)
        
	"""
#        exit = QAction('Exit', self)
#        exit.setShortcut('Ctrl+Q')
#        exit.setStatusTip('Exit application')
#        self.connect(exit, SIGNAL('triggered()'), SLOT('close()'))
#
#        self.statusBar()
#
#        menubar = self.menuBar()
#        file = menubar.addMenu('&File')
#        file.addAction(exit)
#
#        toolbar = self.addToolBar('Exit')
#        toolbar.addAction(exit)
#        
	"""

app = QApplication(sys.argv)
#main = MainWindow()
#main.show()

s = EventWidget()

r0 = AbsRecord()
r1 = AbsRecord()
r2 = AbsRecord()

r0.add("start", "09:00")
r0.add("end",   "11:30")

r1.add("start", "12:00")
r1.add("end",   "15:15")

r2.add("start", "17:00")
r2.add("end",   "21:00")

s.add(r0)
s.add(r1)
s.add(r2)

print
print r0.get("start"), "-", r0.get("end")
print r1.get("start"), "-", r1.get("end")
print r2.get("start"), "-", r2.get("end")
s.show()
sys.exit(app.exec_())

